﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine.Scenes;
using Microsoft.Xna.Framework;
using GameEngine.Managers.IManagers;
using PvT.Entities;
using Microsoft.Xna.Framework.Graphics;
using GameEngine.Camera;
using GameEngine.EntityComponents;
using GameEngine.Factory;


namespace PvT.Scenes.Factory
{
    public class ConcreteFactory : AbstractFactory
    {
        /// <summary>
        /// Gets a level, in this case of the type SceneWrapper that contains a past and future level.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <param name="sceneName">Name of the scene.</param>
        /// <param name="sceneOut">The scene out.</param>
        public override void GetLevel(Game game, string sceneName, out Scene sceneOut)
        {
            GameHudEntity gameHud = new GameHudEntity(new List<GameEngine.EntityComponents.IEntityComponent>(), true, true, new Vector2(0, 0), game);
            gameHud.LoadContent();

            PlayerEntity playerEntity = new PlayerEntity(new List<GameEngine.EntityComponents.IEntityComponent>(), true, true, new Vector2(70, 30), game);
            playerEntity.LoadContent();
            gameHud.SetPlayer(playerEntity);

            EnemyEntity enemyEntity = new EnemyEntity(new List<GameEngine.EntityComponents.IEntityComponent>(), true, true, new Vector2(530, 150), game);
            enemyEntity.LoadContent();

            VortexEntity vortex1 = new VortexEntity(new List<IEntityComponent>(), true, true, new Vector2(970, 80), game);
            vortex1.LoadContent();

            VortexEntity vortex2 = new VortexEntity(new List<IEntityComponent>(), true, true, new Vector2(90, 220), game);
            vortex2.LoadContent();

            VortexEntity vortex3 = new VortexEntity(new List<IEntityComponent>(), true, true, new Vector2(1030, 340), game);
            vortex3.LoadContent();

            PowerUpEntity powerUp = new PowerUpEntity(new List<IEntityComponent>(), true, true, new Vector2(1210, 520), game);
            powerUp.LoadContent();

            LazerGate lazerGate = new LazerGate(new List<IEntityComponent>(), true, true, new Vector2(970, 0), game);
            lazerGate.LoadContent();

            Skynet skynet = new Skynet(new List<IEntityComponent>(), true, true, new Vector2(1300, 7), game);
            skynet.LoadContent();

            Scene scene = new Past(game);
            scene.AddLayer(new Layer2D(game));
            scene.AddLayer(new Layer2D(game));
            scene.AddLayer(new Layer2D(game));
            scene.SetBackgroundLayer(scene.background, 0);
            scene.SetBackgroundLayer(game.Content.Load<Texture2D>("Scenes/Past/foreground2"), 2);
            scene.SetBackgroundLayer(game.Content.Load<Texture2D>("Scenes/Past/spikes"), 3);
            scene.AddEntityToLayer(gameHud, 2);
            scene.AddEntityToLayer(playerEntity, 0);
            scene.AddEntityToLayer(vortex1, 0);
            scene.AddEntityToLayer(vortex2, 0);
            scene.AddEntityToLayer(vortex3, 0);
            scene.AddEntityToLayer(enemyEntity, 0);
            scene.isActive = true;
            scene.PlayBackgroundSound();
            ((Camera2D)game.Services.GetService(typeof(Camera2D))).Limits =
                    new Rectangle(0, 0, scene.background.Width, scene.background.Height);

            Scene scene2 = new Future(game);
            scene2.SetBackgroundLayer(scene2.background, 0);
            scene2.SetBackgroundLayer(game.Content.Load<Texture2D>("Scenes/Future/plasma"), 3);

            scene2.AddEntityToLayer(gameHud, 3);
            scene2.SetBackgroundLayer(game.Content.Load<Texture2D>("Scenes/Future/foreground2"), 2);
            scene2.AddEntityToLayer(playerEntity, 0);
            scene2.AddEntityToLayer(vortex1, 0);
            scene2.AddEntityToLayer(vortex2, 0);
            scene2.AddEntityToLayer(vortex3, 0);
            scene2.AddEntityToLayer(powerUp, 1);
            scene2.AddEntityToLayer(lazerGate, 0);
            scene2.AddEntityToLayer(skynet, 1);
            scene2.isActive = false;

            sceneOut = new Prison(game, scene, scene2);
        }
    }
}
